package com.kate.mall.bff.wx.java8;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author 新梦想.陈超
 * @version 2021.2
 * @Description: {TODO}
 * @date 2023/3/13 下午4:17
 */

public class _02_Construct_Ref {
    public  void test01() {
        Supplier<Employee> supplier = () -> new Employee("张三", 18, 13);

        // 构造器引用（调用的无参构造器）
        Supplier<Employee> supplier1 = Employee::new;
        Employee employee = supplier1.get();

        // 构造器引用（调用有参构造器，一个参数的）
        Function<Integer, Employee> function = Employee::new;
        Employee employee1 = function.apply(10);
        System.out.println(employee1.getAge());


        Supplier<Dog> supplier2 = Dog::new;
        Dog dog = supplier2.get();
        System.out.println(dog.getName());

        Function<String,Dog> function1= Dog::new;
        Dog lf = function1.apply("来福");
        System.out.println(lf.getName());
    }

}

class Dog {
    private String name;
    public Dog(){
        this.name="旺财";
    }
    public Dog(String name){
        this.name=name;
    }
    public String getName(){
        return this.name;
    }

}
